/*
 * $Id: BaseObjectsLoadResult.java 136 2009-07-16 07:53:43Z donbeave $
 */

package labour.concept.client.data;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.data.BaseListLoadResult;

@SuppressWarnings("serial")
public class BaseObjectsLoadResult<D extends ObjectModel> extends BaseListLoadResult<D> implements ObjectsLoadResult<D> {

  protected List<ObjectTextModel> texts;
//  protected List<BlockModel> blocks;

  public BaseObjectsLoadResult(List<D> data, List<ObjectTextModel> texts) {
    super(data);

    this.texts = texts;
  }

  public List<ObjectTextModel> getTexts() {
    return texts;
  }

  public List<ObjectTextModel> getTexts(ObjectModel model) {
    List<ObjectTextModel> list = new ArrayList<ObjectTextModel>();

    for (ObjectTextModel text : texts) {
      if ((model.isExist() && text.getObjectId().equals(model.getId())) ||
          text.getObjectUId().equals(model.getUId())) {
        list.add(text);
      }
    }
    return list;
  }

}